// packageK/Juxin/threeArchitecture.js
var o = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tabInd: 1,
    page:1,
    isLoding:false,
    uid:'',
    keyword:'',
    list:[],
    total:0,
    isShow:true
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    // uid: wx.getStorageSync('uid') || wx.getStorageSync('yz_uid')133687 ||
    let u = options && options.uid ? options.uid :  wx.getStorageSync('uid') || wx.getStorageSync('yz_uid')
    this.setData({
      uid:u,
      isShow: options && options.uid ? false : true
    })
    this.getData()
  },

  selectTab(e) {
    let t = e.currentTarget.dataset.tab
    if (this.data.tabInd == t) return
    this.setData({
      tabInd: t,
      page: 1,
      isLoding: true,
      list:[],
      total:0
    })
    this.getData()
  },
  // 获取数据
  getData(){
    var t = o.getNetAddresss("Juxin.jiagouMember");
    let e = this
    o._postNetWork({
        url: t,
        data:{
            uid:this.data.uid,
            type:this.data.tabInd,
            keyword:this.data.keyword,
            page:this.data.page
        },
        success(l){
            let i = l.data
            console.log(i);
            if(i.result == 1){
              let arr = [...e.data.list,...i.data.data]
              e.setData({
                list:arr,
                total:i.data.total,
              })
            }else{
              wx.showToast({
                title:i.msg,
                icon:'none'
              })
            }
            e.setData({
              isLoding: false,
            })
        }
    })
  },
  // 输入框
  getInput(e){
    this.setData({
      keyword:e.detail.value
    })
  },
  // 搜索
  getSearch(){
    this.setData({
      page:1,
      isLoding:true,
      list:[]
    })
    this.getData()
  },
  // 跳转
  To(e){
    let u = e.currentTarget.dataset.item.uid
    wx.navigateTo({
      url: '/packageK/Juxin/threeArchitecture?uid='+u,
    })
  },


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
    if(this.data.total > this.data.list.length && !this.data.isLoding){
      this.setData({
        page:this.data.page+=1,
        isLoding:true
      })
      this.getData()
    }
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})